/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package multithreadserver;
import java.net.*;
import java.io.*;
import java.util.ArrayList;


/**
 *
 * @author Brady Itkin
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static ArrayList socklist= new ArrayList(10);
    public static void main(String[] args) throws IOException {
       int accepts = 0;
       boolean listening = true;
       ServerSocket sock = null;
       Socket newsock =null;
       
       try {
           sock = new ServerSocket(4445);
       }
       catch (IOException e){
           e.printStackTrace();
           System.err.println("Couldn't listen on port 4445, try a different port");
           System.exit(1);
       }
       while (listening) {
           newsock=sock.accept();
           socklist.add(newsock);
           new thread(newsock).start();
           accepts++;
           if (accepts==2) break;
       }
       sock.close();
    }
}
